package com.atguigu.gulimall.order.listener;

import com.atguigu.common.vo.mq.SecKillOrderTo;
import com.atguigu.gulimall.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @create: 2024/9/17
 * @author: gyhe10
 * @description: 监听 order.seckill.order.queue 队列消息
 **/

@Slf4j
@RabbitListener(queues = {"order.seckill.order.queue"})
@Component
public class OrderSeckillListener {

    @Resource
    private OrderService orderService;

    @RabbitHandler
    public void listener(SecKillOrderTo secKillOrderTo) {
        log.info("监听到秒杀订单消息，准备创建订单");
        orderService.createSeckillOrder(secKillOrderTo);
    }
}
